window.onload = function() {
    var vm = new Vue({
      el: "#brand",
      data: {
        brandId:"",
        brandkeywords:"",
        brandBaseInfo:{},
        communityImpressList:[],
        brandHotPushList:{},
        brandOptionList:[]
      },
      created: function() {
        this.brandId = this.getParams("id");
        this.getBrandBaseInfo();
        this.getCommunityImpress();
        this.getBrandHotPush();
        this.getBrandOption();
        this.addVisit();
      },
      methods: {
        //品牌基本信息
        getBrandBaseInfo(){
            var $this = this;
            house_server.getBrandBaseInfo({ brandId: this.brandId }, function(data) {
                $this.brandBaseInfo = data.data;
              });
        },
        //社区印象
        getCommunityImpress: function() {
            var $this = this;
            house_server.getCommunityImpress({ brandId: this.brandId }, function (data) {
                $this.communityImpressList = data.data;
            });
          },
        //热推空间
        getBrandHotPush: function() {
            var $this = this;
            house_server.getBrandHotPush({ brandId: this.brandId }, function (data) {
                $this.brandHotPushList = data.data;
            });
          },
          //会员见解
          getBrandOption: function() {
            var $this = this;
            house_server.getBrandOption({ brandId: this.brandId }, function (data) {
                $this.brandOptionList = data.data;
            });
          },
          checkDetail: function(id) {
            window.location.href = "./community.html?id=" + id + "";
          },
          //搜索
          goToEntry() {
              window.location.href = './../search/entry.html?type=2';
          },
          // showTel(){
          //     var $this = this;
          //     var dialog = new auiDialog({})
          //     dialog.alert({
          //         msg:$this.brandBaseInfo.serviceTel ,
          //         buttons:['确定']
          //     },function(ret){
          //         // console.log(ret)
          //     })
          // },
          //添加浏览量
          addVisit: function() {
              var $this = this;
              house_server.addVisit({
                id: $this.brandId,
                type: "9"
              }, function (res) {
                // console.log(res);
              });
          },
        goSearch(type){
          window.location.href = './../search/search-result-community.html?brandId='+this.brandId +'&type='+type;
        },
        goHome(){
          window.location.href = "/home/html/";
        },
        //图片解析
        getImgUrl: function() {
          var ip = window.location.host,
            url = "";
          if (ip.indexOf("127.0.0.1") >= 0 || ip.indexOf("localhost") >= 0) {
            url = "http://114.113.68.14:9000/image/";
          } else if (ip.indexOf("www.") >= 0) {
            url = "http://image.3dzhixuan.com/image/";
          } else {
            url = "http://" + ip + "/image/";
          }
          return url;
        },
        // 获取参数
        getParams(name) {
          var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
          var r = window.location.search.substr(1).match(reg);
          if (r != null) return unescape(r[2]);
          return null;
        }
      }
    });
  };
  